package com.hll.iot;

import cn.hutool.core.lang.Dict;
import com.aos.iot.protocol.hll.constant.HllCmd;
import com.aos.iot.protocol.hll.constant.HllProp;
import com.aos.iot.protocol.hll.message.HllMessage;

public class HllMessageHelper {

    private final static String HEAD = "55AA";

    /**
     * 创建-服务器主动获取某个通道信息指令
     */
    public static HllMessage createQueryPipe(String clientId, String version, String encrypt, String pipeNo) {
        return createMessage(clientId, version, encrypt, HllCmd.QUERY_POTENTIAL_INFO,
                Dict.create().set(HllProp.PILE_NO.getValue(), clientId)
                .set(HllProp.PIPE_NO.getValue(), pipeNo)
        );
    }

    /**
     * 创建消息
     */
    private static HllMessage createMessage(String clientId, String version, String encrypt, String cmd, Dict data) {
        HllMessage message = new HllMessage();
        message.setHead(HEAD);
        message.setVersion(version);
        message.setEncrypt(encrypt);
        message.setCmd(cmd);
        message.setData(data);
        return message;
    }
}
